<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//http://localhost:8080/logistics/
%>
<!DOCTYPE HTML>
<html>
<head>
<!-- 设置页面的 基本路径，页面所有资源引入和页面的跳转全部基于 base路径 -->
<base href="<%=basePath%>">

<link rel="stylesheet" href="lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="lib/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="lib/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>



<ul id="permissionTree" class="ztree"></ul>


</body>

<script type="text/javascript">
	//1.zTree 设置 默认为控
	var setting = {
		check: {enable: true},
		data: {
			simpleData: {
				enable: true,
				pIdKey:'parentId',
				idKey:'permissionId'
			}
		},
		//异步加载
		async:{
			enable: true,
			url:'permission/getAllPermission.do',
			//异步加载过滤设置：在zTree渲染之前过滤
			dataFilter: filter
		}
		
	};
	//异步加载数据完毕以后过滤函数，可以在此函数中过滤器原有的数据或者在原有数据上新增数据
	function filter(treeId, parentNode, childNodes) {
		console.log(treeId,parentNode,childNodes);
		
		//循环出所有数据，并且新增一个open属性
		for (var i=0;i<childNodes.length;i++) {
			var childNode = childNodes[i];
			childNode.open=true;
		}
		console.log(treeId,parentNode,childNodes);
		return childNodes;
	}


	$(function(){
		//初始化zTree
		$.fn.zTree.init($("#permissionTree"), setting);
	});


</script>

</html>